<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>绝对定位</title>

    <style>
        .one,.two,.three{
            width: 100px;
            height: 100px;
        }

        .one{
            background: blue;
        }

        .two{
            background: tomato;
            /*绝对路径 在没有上一级标签的情况下 是 以html或者body为基准的*/
            position: absolute;
            left: 100px;
            top: 100px;
        }

        .three{
            background: green;
        }

        .other{
            width: 200px;
            height: 200px;
            background: red;
            position: relative;
            left: 200px;
        }

        .inner{
            width: 100px;
            height: 100px;
            background: purple;
            /*此时的绝对路径是 以 上一级的父类为基准*/
            position: absolute;
            left: 100px;
            top: 100px;
        }


        .grand{
            width: 300px;
            height: 300px;
            background: yellow;
            /*这里的父类设置了相对路径*/
            position: relative;
            left: 400px;
        }

        .father{
            width: 200px;
            height: 200px;
            background: beige;
            /*这里的绝对路径 是 相对于 父类*/
            position: absolute;
            left: 200px;
        }

        .son{
            width: 100px;
            height: 100px;
            background: brown;
            /*这里的绝对路径 是 相对于 父类*/
            position: absolute;
            left: 100px;
            top: 100px;
        }

    </style>



</head>
<body>



<div class="one"></div>
<div class="two"></div>
<div class="three"></div>

<div class="other">
    <div class="inner"></div>
</div>


<div class="grand">
    <div class="father">
        <div class="son"></div>
    </div>
</div>

</body>
</html>